﻿using System;
using System.Data;
using System.Text;
using System.Data.SqlClient;
using DBUtility;//请先添加引用
namespace TierApplication
{
    public partial class T_Supplier
    {
        #region User define
        public bool IsExistsProduct(string sSupplierID)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select count(1) from T_Product where SupplierID='" + sSupplierID + "'");
            return DbHelperSQL.Exists(strSql.ToString());
        }


        public DataSet GetPayList(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select Od.*,AllPay-BckMoney-Payed NeedPay from ");
            strSql.Append("(");
            strSql.Append("select SupplierID,SupplierName,");
            strSql.Append("Isnull(Sum(SumPrice),0) AllPay,");
            strSql.Append("(Select Isnull(Sum(SumPrice),0) from S_OrderDetail where SupplierID=a.SupplierID and  OrderStatus ='2' and OrderType='3') BckMoney,");
            strSql.Append("(Select Isnull(Sum(PayMoney),0) from T_SupplierPay where SupplierID=a.SupplierID) Payed");
            strSql.Append(" from S_OrderDetail a");
            strSql.Append(" where OrderStatus ='2'");
            strSql.Append(" and OrderType='2'");
            strSql.Append(" group by SupplierID,SupplierName");
            strSql.Append(") Od");
            return DbHelperSQL.Query(strSql.ToString());
        }

        #endregion

    }
}

